$(function(){

});
function login() {
    var userName = $("#userName").val();
    var password = $("#password").val();
    if(!userName || !password){
        alert("请输入用户名或密码")
        return ;
    }

    $.ajax({
        type: "POST",
        url: "http://localhost:8080/login",
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        data: {"loginName":userName,"password":password},
        dataType : "json",
        error: function () {

        },
        success: function (result) {
            if (result) {
                window.location.href="/index";
            }
        }
    });
}

